<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head>

<body>
    <button></button>
    <script>
        let btn = document.querySelector('button');
        // 设置请求拦截器
        axios.interceptors.request.use(function (config) {
            console.log('请求拦截器成功');
            config.params = {
                a: 100,
                b: 10
            }
            return config;
        }, function (error) {
            // Do something with request error
            console.log('请求拦截器失败');
            return Promise.reject(error);
        });

        // Add a response interceptor
        axios.interceptors.response.use(function (response) {
            // Any status code that lie within the range of 2xx cause this function to trigger
            // Do something with response data
            console.log('响应拦截器成功');
            return response;
        }, function (error) {
            // Any status codes that falls outside the range of 2xx cause this function to trigger
            // Do something with response error
            console.log('响应拦截器失败');
            return Promise.reject(error);
        });
        btn.onclick = function () {

            axios({
                //请求类型
                method: 'GET',
                url: 'https://autumnfish.cn/hot/topic?limit=30&b=5'


            }, ).then(response => {
                console.log(response);
            })
        }
    </script>
</body>

</html>